package univers;

import java.util.ArrayList;
import java.util.List;
import static univers.EspaceAffine.Vecteur.*;
import univers.EspaceAffine.Point;
import univers.EspaceAffine.Vecteur;
import static univers.EspaceAffine.Z.*;

public class Chemin {

    private Avatar A;
    List<Point>[][] chemin;

    public Chemin(Avatar avatar) throws CloneNotSupportedException {
        A = avatar;
        chemin = new ArrayList[9][9];
        caseParCase();
    }

    private void caseParCase() throws CloneNotSupportedException {
        boolean limite = false;
        List<Point> list;

        while (!limite) {
            while (!limite) {
                //                System.out.println(A.position);
                list = enEtoile();
                chemin[A.position.X.I][A.position.Y.I]=new ArrayList<Point>();
                chemin[A.position.X.I][A.position.Y.I].addAll(list);
                limite = A.vers(est);
            }
            A.vers(nord);
            limite = A.vers(_8, ouest);
        }
    }

    private List<Point> enEtoile() throws CloneNotSupportedException {
        List<Point> list = new ArrayList<Point>();
        Point point_depart = (Point) A.position.clone();
        boolean limite = false;
        for (Vecteur direction : Direction) {
        list.add(direction.toPoint());
            while (!(limite)) {
                list.add(A.position);
//                System.out.print(A.position);
                limite = A.vers(direction);
            }
            list.add(EspaceAffine.Frontiere);
            A.position = (Point) point_depart.clone();
            limite = false;
        }
        return list;
    }

    public List<Point>[][] getChemin() {
        return chemin;
    }

}









